home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / What's New? / Technical Documentaion / Macintosh Technotes and Q&As / technotes / tn / energyservapi.hqx / EnergyServPub.h next >
Encoding:
Text File  |  1996-12-07  |  8.2 KB  |  227 lines

  1. // EnergyServPub.h
  2. // Apple Macintosh Developer Technical Support
  3. //
  4. //    Contains:    Header file for the ESInit.
  5. //
  6. //  Copyright (work in progress)  Apple Computer, Inc All rights reserved.
  7. //
  8. // You may incorporate this sample code into your applications without
  9. // restriction, though the sample code has been provided "AS IS" and the
  10. // responsibility for its operation is 100% yours.  However, what you are
  11. // not permitted to do is to redistribute the source as "DSC Sample Code"
  12. // after having made changes. If you're going to re-distribute the source,
  13. // we require that you make it clear in the source that the code was
  14. // descended from Apple Sample Code, but that you've made changes.
  15.  
  16. #ifndef __TYPES__
  17. #include <Types.h>
  18. #endif
  19. /*    #include <ConditionalMacros.h>                                */
  20.  
  21. #ifndef __QUICKDRAW__
  22. #include <Quickdraw.h>
  23. #endif
  24. /*    #include <MixedMode.h>                                        */
  25. /*    #include <QuickdrawText.h>                                    */
  26.  
  27. #pragma options align=mac68k
  28. typedef struct {
  29.  
  30.     short            version;                // version of the data structure this one is 1
  31.     long            EnergySaverFeatures;    // a long showing what features are supported 
  32.  
  33. // Idle Sleep & ShutDown stuff
  34. // the following are defined in minutes.
  35. //  0 minutes, or >60 minutes means never
  36.  
  37.     unsigned long     dimIdleTime;            //number of minutes before the screen sleeps
  38.     unsigned long     spinDownIdleTime;        //number of minutes before the HD spins down ( desktops must be >30 for now)
  39.     unsigned long     sleepIdleTime;            //number of minutes prior to system sleep
  40.  
  41.     short            idleFlags;                // defines which idle time features we support
  42.     short            unused6;                // reserved 
  43.     short            unused7;                // reserved
  44.  
  45. // Schedule Sleep & Shut Down stuff
  46. //    These times are in minutes from midnight (actually minutes from 12:00:01 AM...)
  47.  
  48.     unsigned long     mainWUTime;                // Time computer starts up in general
  49.     unsigned long     mainSDTime;                // time computer shuts down in general
  50.  
  51.     short            WUFields;                // bit fields telling which day of the week startup is enabled for
  52.     short            SDFields;                // bit fields telling which day of week shutdown is enabled for
  53.  
  54. // usually the same as the in general time, but the following 14 fields let you specify different times of the day
  55. // for startup and shutdown for each individual day. You should set all WU's to mainWUTime and all SD fields to mainSDTime
  56. // if you are not going to allow specific daily schedules. This is what energysaver does.
  57.     unsigned long     SDMonTime;
  58.     unsigned long     SDTueTime;
  59.     unsigned long     SDWedTime;
  60.     unsigned long     SDThuTime;
  61.     unsigned long     SDFriTime;
  62.     unsigned long     SDSatTime;
  63.     unsigned long     SDSunTime;
  64.  
  65.     unsigned long     WUMonTime;
  66.     unsigned long     WUTueTime;
  67.     unsigned long     WUWedTime;
  68.     unsigned long     WUThuTime;
  69.     unsigned long     WUFriTime;
  70.     unsigned long     WUSatTime;
  71.     unsigned long     WUSunTime;
  72.  
  73. // Sleep Prefs Info stuff
  74.     short            unused1;        
  75.     short            WUSoundResID;        // ID of the sound resource to play when waking up from sleep
  76.     short            unused5;         
  77.  
  78. // Startup Prefs Info
  79.     short            SUReopenFiles;        // flags that define how we do the shutdown/restart file saving crap
  80.     short            AppFlags;            // Always set to 0 in new pref file.  
  81.     short            NonComplianceFlag;    // set if base machine sleeps over 30 watts
  82.  
  83. // Shutdown Prefs Info
  84.     short            SDIdleTime;            
  85.     short            SDNotifyFlags;
  86.     short            SDNotifyDelayTime;
  87.     short            SDSoundResID;
  88.     short            SDNewFileAlias;
  89.     short            SDSavedFileAlias;
  90.  
  91. // Energy Saver General prefs info
  92.     Point            oldWin300Pos;        // don't use this, it belongs to the energysaver 
  93.     Boolean            unused8;        
  94. } GlobDataRecord, *GlobDataPtr, **GlobDataHand;
  95.  
  96.  
  97.  
  98.  
  99. #define    xESLoadPreferences    1
  100. #define xESGetPreferences    2
  101. #define xESSetPreferences    3
  102. #define xESRefreshSettings    4
  103. #define xESSavePreferences    5
  104. #define xESAddNoteProc        6
  105. #define xESRemoveNoteProc    7
  106. #define xESRestoreDefaults    8
  107. #define xESGetUnsavedFolder    9
  108. #define    xESSetUnsavedFolder    10
  109. #define xESGetINITVersion    11
  110. #define xESGetAliasFileName    12
  111.  
  112. #define xNoteNewESData        1
  113. #define xNoteESDataReq        2
  114.  
  115. typedef    pascal long (*ESRoutineCallPtr)(short    selector, long    parm1, long    parm2);
  116. typedef pascal long (*ESNotifyProcPtr)(short selector, GlobDataPtr theData);
  117.  
  118. #if GENERATINGCFM
  119. typedef UniversalProcPtr ESRoutineUPP;
  120. #else
  121. typedef ESRoutineCallPtr ESRoutineUPP;
  122. #endif
  123.  
  124. enum {
  125.     uppESRoutineInfo = kPascalStackBased
  126.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  127.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  128.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  129.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  130. };
  131.  
  132. #if GENERATINGCFM
  133. #define NewESRoutineProc(userRoutine)        \
  134.         (ESRoutineUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppESRoutineInfo, GetCurrentArchitecture())
  135. #else
  136. #define NewESRoutineProc(userRoutine)        \
  137.         ((ESRoutineUPP) (userRoutine))
  138. #endif
  139.  
  140. #if GENERATINGCFM
  141. #define CallESRoutineProc(userRoutine, selector, parm1, parm2)        \
  142.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppESRoutineInfo, (selector), (parm1), (parm2))
  143. #else
  144. #define CallESRoutineProc(userRoutine, selector, parm1, parm2)        \
  145.         (*(userRoutine))((selector), (parm1), (parm2))
  146. #endif
  147.  
  148. typedef struct {
  149.     ESRoutineCallPtr    WinkleINITMain;            /* Main entry point for the Winkle INIT */
  150.     char                RestOfTheData[1];
  151. } ESData, *ESDataPtr, **ESDataHand;
  152. #pragma options align=reset
  153.  
  154.  
  155. // Public routines used by calling applciations
  156. // The ESLoadPreferences routine will fill the GlobDataPtr passed with the
  157. // preferences from the energy saver prefs file
  158. // or from the default set if the energy saver pref file does not exist.
  159. // Applications should not use this in general unless
  160. // they are reverting to the saved version for some reason
  161.  
  162. OSErr    ESLoadPreferences(GlobDataPtr thePrefs);
  163.  
  164. // Load the current working prefs that the energy services library is
  165. // using. This will tell you what the current active
  166. // settings are for the energy services lib.
  167.  
  168. OSErr    ESGetPreferences(GlobDataPtr thePrefs);
  169.  
  170. // ESSetPreferences simply updates the energy services libraries
  171. // preferences without applying the changes. Apps should not use this call
  172. // unless they are simply trying to communicate the information at suspend
  173. // time. (you know the suspend event...)
  174.  
  175. OSErr    ESSetPreferences(GlobDataPtr thePrefs);
  176.  
  177. // ESRefreshSettings takes whatever settings the INIT currently is holding
  178. // and applies them. You could use this in conjunction with
  179. // ESSetPreferences, except that would be stupid since the next call.,..
  180.  
  181. OSErr    ESRefreshSettings();
  182.  
  183. // ESSavePreferences copies the passed prefs to the INIT, applies the
  184. // changes to the power manager and running time manager tasks
  185. // and saves them to the energy saver prefs file so that when you reboot
  186. // life is good. This is how you should usually save
  187. // the prefs to the INIT
  188.  
  189. OSErr    ESSavePreferences(GlobDataPtr thePrefs);
  190.  
  191. // ESAddNoteProc, ESRemoveNoteProc are here so that if you care about when
  192. // the energy saver prefs are being read or written you can be notified
  193. // your notification procedure is called when someone is asking for the
  194. // prefs you will be called with the filled in GlobData and the
  195. // selector xNoteESDataReq. This way you can see when someone wants the
  196. // prefs and you could always modify them on the fly if you wanted to
  197. // You are also called when someone copies new prefs to the INIT with a
  198. // xNoteNewESData selector. You then get a chance to change the data that
  199. // they have copied into the INIT, but you get to it before its applied. I
  200. // use these routines to dynamically update the displays of my apps
  201. // not to filter data, but I suppose you could do either.
  202.  
  203. OSErr    ESAddNoteProc(ESNotifyProcPtr theProc, long data);
  204. OSErr    ESRemoveNoteProc(ESNotifyProcPtr theProc);
  205.  
  206. // ESRestoreDefaults is used to put the machine back in the exact state it
  207. // was when it was shipped. You also get a copy of the globdata
  208. // so that you can see what those defaults are. Getting the globdata is
  209. // convenient so that you can update your HI to reflect the current machine state
  210. // use this in response to a "Apple Defaults" menu item maybe...
  211.  
  212. OSErr    ESRestoreDefaults(GlobDataPtr thePrefs);
  213.  
  214. // ESGetUnsavedFolder, ESSetUnsavedFolder are dumb, and not really anything
  215. // you should use. So don't, or do see what I care.
  216.  
  217. OSErr    ESGetUnsavedFolder(Ptr    theString);
  218. OSErr    ESSetUnsavedFolder(Ptr    theString);
  219.  
  220. // ESGetINITVersion will return a copy of the vers resource from the INIT 
  221. // so's you can see what version you are working with
  222.  
  223. OSErr    ESGetINITVersion(Handle* theVers);
  224.  
  225.  
  226.  
  227.